<?php
/****
	适配器模式
****/
header('Content-type:text/html;charset=utf-8');

//服务器端代码
class Weather{
	public static function show(){
		$today = array('wind'=>7,'sun'=>'sunny');
		return serialize($today);
	}
}

//增加一个适配器
class AdapterWeather extends Weather{
	public static function show(){
		$today = parent::show();
		$today = unserialize($today);
		return json_encode($today);
	}
}


//=========客户端调用==========//
$today = unserialize(Weather::show());
echo "风力：".$today['wind']."</br>";
echo "sun：".$today['sun']."</br>";


//其他客户端调用，通过适配器调用
$today = AdapterWeather::show();
$today = json_decode($today,true);
echo "风力：".$today['wind']."</br>";
echo "sun：".$today['sun']."</br>";
